﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FrameWork.Components;
using System.Collections;

namespace FrameWork.web.Module.IntegralMS.IntegralMS.StudentManager
{
    public partial class Index : System.Web.UI.Page
    {
        public string S_ClassID_ID = "";
        public string S_ClassID_Txt_ID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            S_ClassID_ID = S_ClassID.UniqueID;
            S_ClassID_Txt_ID = S_ClassID_Txt.UniqueID;
            if (!Page.IsPostBack)
            {
                TabOptionWebControls1.SelectIndex = 0;
                BindData();
            }
        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string S_Name_Value = (string)Common.sink(S_Name.UniqueID, MethodType.Post, 20, 0, DataType.Str);
            string S_ClassID_Value = (string)Common.sink(S_ClassID.UniqueID, MethodType.Post, 255, 0, DataType.Str);
            string SqlSearch = " Where S_State<>2 ";
            if (S_Name_Value != "")
            {
                SqlSearch += " and S_Name like '%" + Common.inSQL(S_Name_Value) + "%'";
            }
            if (S_ClassID_Value != "")
            {
                SqlSearch += " and S_ClassID=" + Common.inSQL(S_ClassID_Value);
            }
            ViewState["SearchTerms"] = SqlSearch;
            BindData();
            TabOptionWebControls1.SelectIndex = 0;
        }
        private void BindData()
        {
            QueryParam qp = new QueryParam();
            qp.Where = SearchTerms;
            qp.PageIndex = AspNetPager1.CurrentPageIndex;
            qp.PageSize = AspNetPager1.PageSize;
            int RecordCount = 0;
            ArrayList lst = BusinessFacade.stu_StudentInfoList(qp, out RecordCount);
            GridView1.DataSource = lst;
            GridView1.DataBind();
            this.AspNetPager1.RecordCount = RecordCount;
        }
        /// <summary>
        /// 查询条件
        /// </summary>
        private string SearchTerms
        {
            get
            {
                //if (ViewState["SearchTerms"] == null)
                //    ViewState["SearchTerms"] = " Where U_Status<>2";
                return (string)ViewState["SearchTerms"];
            }
            set { ViewState["SearchTerms"] = value; }
        }
        /// <summary>
        /// 班级名称
        /// </summary>
        /// <param name="S_ClassID"></param>
        /// <returns></returns>
        public string Get_ClassID(int S_ClassID)
        {
            return BusinessFacade.stu_ClassInfoDisp(S_ClassID).C_CName;
        }
        /// <summary>
        /// 获取学员状态
        /// </summary>
        /// <param name="U_Status"></param>
        /// <returns></returns>
        public string GetStat(int S_State)
        {
            if (S_State == 0)
            {
                return "正常";
            }
            else
            {
                return "禁止";
            }
        }
    }

}